package leetcode.linkedlist;

import leetcode.linkedlist.common.LinkedListUtils;
import leetcode.linkedlist.common.ListNode;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 * int val;
 * ListNode next;
 * ListNode() {}
 * ListNode(int val) { this.val = val; }
 * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution876 {
    public ListNode middleNode(ListNode head) {
        return LinkedListUtils.middleNode(head);

    }
}

public class leetcode876 {
    public static void main(String[] args) {
        Solution876 solution876 = new Solution876();
        int[] nums = {1, 2, 3, 4, 5};
        test876(solution876, nums);
    }

    private static void test876(Solution876 solution876, int[] nums) {
        ListNode head = solution876.middleNode(LinkedListUtils.generateLinkedListByArray(nums));
        System.out.println(LinkedListUtils.getLinkedListVals(head));
    }
}
